package com.maxd.adapter;


import com.maxd.model.UserInfo;

public class LoginUserHolder {

    private static ThreadLocal<UserInfo> userInfo = new ThreadLocal<>();

    private static ThreadLocal<String> adminId = new ThreadLocal<>();

    public static void setUserInfo(UserInfo userInfo) {
        LoginUserHolder.userInfo.set(userInfo);
    }

    public static void removeUserInfo() {
        LoginUserHolder.userInfo.remove();
    }

    public static UserInfo getUserInfo() {
        return LoginUserHolder.userInfo.get();
    }

    public static Long getUserId() {
        UserInfo userInfo = getUserInfo();
        return userInfo == null ? null : userInfo.getId();
    }

    public static String getAdminId() {
        return LoginUserHolder.adminId.get();
    }

    public static void setAdminId(String adminId) {
        LoginUserHolder.adminId.set(adminId);
    }

    public static void removeAdminId() {
        LoginUserHolder.adminId.remove();
    }

}
